# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=font-awesome
_pkgname=Font-Awesome
pkgver=6.4.2
_majorver=${pkgver%%.*}
pkgrel=1
pkgdesc="Iconic font set"
url="https://fontawesome.com"
arch="noarch"
license="OFL-1.1"
provides="ttf-font-awesome=$pkgver-r$pkgrel"  # for backward compatibility (Alpine <3.17)
depends="
	$pkgname-brands=$pkgver-r$pkgrel
	$pkgname-free=$pkgver-r$pkgrel
	"
subpackages="
	$pkgname-brands
	$pkgname-free
	"
source="https://github.com/FortAwesome/Font-Awesome/archive/$pkgver/$pkgname-$pkgver.tar.gz
	45-$pkgname.conf.in
	65-$pkgname.conf.in
	Trademarks.md
	"
builddir="$srcdir/$_pkgname-$pkgver"
options="!check"  # N/A

prepare() {
	default_prepare

	mkdir -p fontconfig
	local tmpl; for tmpl in "$srcdir"/*-$pkgname.conf.in; do
		sed "s/@@VERSION@@/$_majorver/" "$tmpl" > fontconfig/"$(basename "$tmpl" .in)"
	done
}

package() {
	mkdir -p "$pkgdir"
}

brands() {
	pkgdesc="The Font Awesome $_majorver Brands icons font (OTF)"
	depends="fontconfig $pkgname-free=$pkgver-r$pkgrel"

	cd "$builddir"
	install -D -m644 otfs/*Brands-*.otf -t "$subpkgdir"/usr/share/fonts/$pkgname/
	install -D -m644 "$srcdir"/Trademarks.md -t "$subpkgdir"/usr/share/licenses/$pkgname/
}

free() {
	pkgdesc="The Font Awesome $_majorver Free icons font (OTF)"
	depends="fontconfig"

	cd "$builddir"
	install -D -m644 otfs/*Free-*.otf -t "$subpkgdir"/usr/share/fonts/$pkgname/
	install -D -m644 fontconfig/*.conf -t "$subpkgdir"/etc/fonts/conf.avail/

	cd "$subpkgdir"
	mkdir -p etc/fonts/conf.d
	local path; for path in etc/fonts/conf.avail/*; do
		ln -s ../conf.avail/${path##*/} etc/fonts/conf.d/
	done
}

sha512sums="
d1ea99052498a84de5eaccf18b00f15aed9a78a1279feaf54d6dec266dcfe674a1b73e5fef0d82bd53cf8c06df1803919e237c66f0644ccfb144cc898ccd6b51  font-awesome-6.4.2.tar.gz
f931782c213856b2e195f927c0ec5165e6a6fb4390fea15a4f51c13964e6b251c624956ee5e4459c6f276e397f65c2cefb80362d65700013c082590f2d7d8207  45-font-awesome.conf.in
17344aaba09181cffc54e6f25e4cd9488e2e753ed6cde8b84e6c3595de65326a080fedd99311751dc05c19ca490bb12c8b83845761523869fb56ad3f9a243e7a  65-font-awesome.conf.in
b600d90f93d7f9da6dcb6ac3640489a112fdf687b15139d82f092e1c6208236906019888c1b987a1df8835a4133a4660f49d3503836e1e1fac4ad46b9a8c0ec3  Trademarks.md
"
